package com.example.bms.user.service.impl;

import com.example.bms.user.entity.UserEntity;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.common.utils.PageUtils;
import com.example.common.utils.Query;

import com.example.bms.user.dao.StaffDao;
import com.example.bms.user.entity.StaffEntity;
import com.example.bms.user.service.StaffService;
import org.springframework.util.ObjectUtils;


@Service("staffService")
public class StaffServiceImpl extends ServiceImpl<StaffDao, StaffEntity> implements StaffService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<StaffEntity> queryWrapper=new QueryWrapper<StaffEntity>();
        String name =(String) params.get("key");


        if(!ObjectUtils.isEmpty(name)){
            queryWrapper.like("sname",name).
                    or().like("phone",name).
                    or().like("position",name);
        }

        IPage<StaffEntity> page = this.page(
                new Query<StaffEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}